package com.heaven.oj.judge.CodeSandbox;

import com.heaven.oj.judge.CodeSandbox.impl.ExampleCodeSandbox;
import com.heaven.oj.judge.CodeSandbox.impl.RemoteCodeSandbox;
import com.heaven.oj.judge.CodeSandbox.impl.ThirdPartyCodeSandbox;

/**
 * @Description 代码沙箱工厂（根据字符串参数创建指定实例）
 * @Author HeavenDirt
 * @Date 2024/7/23 15:38
 */
public class CodeSandboxFactory {
    /**
     *创建代码沙箱实例
     * @param type 沙箱类型
     * @return CodeSandbox
     * @author HeavenDirt
     * @date 2024/7/23 15:53
     */
    public static CodeSandbox newInstance(String type){
        switch (type){
            case "example":
                return new ExampleCodeSandbox();
            case "remote":
                return new RemoteCodeSandbox();
            case "thirdParty":
                return new ThirdPartyCodeSandbox();
            default:
                return new ExampleCodeSandbox();
        }
    }
}
